/**
 * 
 */
package ai.ann;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/** 
 * @author Object
 * @proyect MyFirstNeuronalNetwork
 * @package neuronalNetwork
 */
public abstract class SynapseDirect {

	/**
	 * @uml.property   name="synapseMatrix"
	 */
	protected double[][] synapseMatrixs;

	/**
	 * Getter of the property <tt>synapseMatrix</tt>
	 * @return  Returns the synapseMatrixs.
	 * @uml.property  name="synapseMatrix"
	 */
	protected double[][] getSynapseMatrix() {
		return synapseMatrixs;
	}

	/**
	 * Setter of the property <tt>synapseMatrix</tt>
	 * @param synapseMatrix  The synapseMatrixs to set.
	 * @uml.property  name="synapseMatrix"
	 */
	public void setSynapseMatrix(double[][] synapseMatrix) {
		synapseMatrixs = synapseMatrix;
	}

	/**
	 * @uml.property   name="outMatrix"
	 */
	protected double[] outMatrixs;

	/**
	 * Getter of the property <tt>outMatrix</tt>
	 * @return  Returns the outMatrixs.
	 * @uml.property  name="outMatrix"
	 */
	protected double[] getOutMatrix() {
		return outMatrixs;
	}

	/**
	 * Setter of the property <tt>outMatrix</tt>
	 * @param outMatrix  The outMatrixs to set.
	 * @uml.property  name="outMatrix"
	 */
	protected void setOutMatrix(double[] outMatrix) {
		outMatrixs = outMatrix;
	}

	/**
	 * @uml.property  name="rows"
	 */
	protected int rows;

	/**
	 * Getter of the property <tt>rows</tt>
	 * @return  Returns the rows.
	 * @uml.property  name="rows"
	 */
	protected int getRows() {
		return rows;
	}

	/**
	 * Setter of the property <tt>rows</tt>
	 * @param rows  The rows to set.
	 * @uml.property  name="rows"
	 */
	protected void setRows(int rows) {
		this.rows = rows;
	}

	/**
	 * @uml.property  name="columms"
	 */
	protected int columms;

	/**
	 * Getter of the property <tt>columms</tt>
	 * @return  Returns the columms.
	 * @uml.property  name="columms"
	 */
	protected int getColumms() {
		return columms;
	}

	/**
	 * Setter of the property <tt>columms</tt>
	 * @param columms  The columms to set.
	 * @uml.property  name="columms"
	 */
	protected void setColumms(int columms) {
		this.columms = columms;
		outMatrixs = new double[columms];
	}
		
	/**
	 * @return 
	 */
	public double[] stimulation(double[] stimulate){
		return null;
	}

		
	public void setSynapseMatrix(String path){
		FileReader fileReader = null;
		BufferedReader bufferedReader = null;
		try {
			fileReader = new FileReader(path);
			bufferedReader = new BufferedReader(fileReader);
		} catch (FileNotFoundException e) {
			System.out.println("[Synapse]-setSynapseMatrix()-Error al Abrir archivo para lectura");
			e.printStackTrace();
		}
		try {
			int i = 0;
			String linea;
			String tokens[];
			while((linea = bufferedReader.readLine())!= null){
				tokens = linea.split(";");
				synapseMatrixs[i][0] = Double.parseDouble(tokens[0]);
				synapseMatrixs[i][0] = Double.parseDouble(tokens[1]);
				synapseMatrixs[i][0] = Double.parseDouble(tokens[2]);
				i++;
			}
			if(i < rows){
				System.out.println("[Synapse]-setSynapseMatrix()-Error la cantidad de datos inferior a la matriz de peso");
			}
		} catch (NumberFormatException e) {
			System.out.println("[Synapse]-setSynapseMatrix()-Error linea leida no es numero");
			e.printStackTrace();
		} catch (IOException e) {
			System.out.println("[Synapse]-setSynapseMatrix()-Error al leer el archivo");
			e.printStackTrace();
		} catch (IndexOutOfBoundsException e) {
			System.out.println("[Synapse]-setSynapseMatrix()-Error la cantidad de datos sobrepasa a la matriz de peso");
			e.printStackTrace();
		}
				
	}

	/**
	 * @uml.property   name="output"
	 * @uml.associationEnd   inverse="input:neuronalNetwork.LayerDirect"
	 * @uml.association   name="Input"
	 */
	protected LayerDirect output;

	/**
	 * Getter of the property <tt>output</tt>
	 * @return  Returns the input.
	 * @uml.property  name="output"
	 */
	protected LayerDirect getOutput() {
		return output;
	}

	/**
	 * Setter of the property <tt>output</tt>
	 * @param output  The input to set.
	 * @uml.property  name="output"
	 */
	protected void setOutput(LayerDirect output) {
		this.output = output;
	}

	/**
	 * @uml.property   name="input"
	 * @uml.associationEnd   inverse="output:neuronalNetwork.LayerDirect"
	 * @uml.association   name="OutPut"
	 */
	private LayerDirect input;

	/**
	 * Getter of the property <tt>input</tt>
	 * @return  Returns the input1.
	 * @uml.property  name="input"
	 */
	protected LayerDirect getInput() {
		return input;
	}

	/**
	 * Setter of the property <tt>input</tt>
	 * @param input  The input1 to set.
	 * @uml.property  name="input"
	 */
	protected void setInput(LayerDirect input) {
		this.input = input;
	}
			
	/**
	 */
	public SynapseDirect(){
	
	}

}
